home *** CD-ROM | disk | FTP | other *** search
/ BBS in a Box 3 / BBS in a box - Trilogy III.iso / Files / Prog / B-C / C++ FAQ Reference 1.0 / C++ FAQ Reference 1.0.rsrc / TEXT_1433.txt < prev    next >
Encoding:
Text File  |  1993-06-30  |  1.4 KB  |  9 lines

  1. A inline virtual member fn is a member fn that is inline and virtual :-). The second question is much harder to answer.  The short answer is 'Yes, but'.
  2.  
  3. A virtual call (msg dispatch) via a ptr or ref is always resolved dynamically (at run-time).  In these situations, the call is never inlined, since the actual code may be from a derived class that was created after the caller was compiled.
  4.  
  5. The difference between a regular fn call and a virtual fn call is rather small. In C++, the cost of dispatching is rarely a problem.  But the lack of inlining in any language can be very Very significant.  Ex: simple experiments will show the difference to get as bad as an order of magnitude (for zillions of calls to insignificant member fns, loss of inlining virtual fns can result in 25X speed degradation! [Doug Lea, 'Customization in C++', proc Usenix C++ 1990]).
  6.  
  7. This is why endless debates over the actual number of clock cycles required to do a virtual call in language/compiler X on machine Y are largely meaningless. Ie: many language implementation vendors make a big stink about how good their msg dispatch strategy is, but if these implementations don't *inline* method calls, the overall system performance would be poor, since it is inlining --*not* dispatching-- that has the greatest performance impact.
  8.  
  9. NOTE: PLEASE READ THE NEXT TWO QUESTIONS TO SEE THE OTHER SIDE OF THIS COIN!